<%@ page language="java" import="java.util.*,java.sql.*"
	pageEncoding="UTF-8"%>
<%@page import="com.bean.LoginBean"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>转正审批</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

</head>

<body>


	<%
		//定义四个分页会用到的变量
		int pageSize = 3;
		int pageNow = 1;//默认显示第一页
		int rowCount = 0;//该值从数据库中查询
		int pageCount = 0;//该值是通过pageSize和rowCount
		//接受用户希望显示的页数（pageNow）
		String s_pageNow = request.getParameter("pageNow");
		if (s_pageNow != null) {
			//接收到了pageNow
			pageNow = Integer.parseInt(s_pageNow);
		}
		//查询得到rowCount
		Class.forName("com.mysql.jdbc.Driver").newInstance();
		String url = "jdbc:mysql://localhost:3306/graduatedesign";
		String user = "root";
		String password = "root";
		Connection conn = DriverManager.getConnection(url, user, password);
		Statement sm = conn.createStatement();
		LoginBean LoginBean = (LoginBean) session.getAttribute("Loginbean");
		String dept = LoginBean.getDept();
		ResultSet rs = sm
				.executeQuery("select count(*) from zhuanzheng where dept ='"
						+ dept+ "'");

		if (rs.next()) {
			rowCount = rs.getInt(1);
		}
		//计算pageCount
		if (rowCount % pageSize == 0) {
			pageCount = rowCount / pageSize;
		} else {
			pageCount = rowCount / pageSize + 1;
		}
		//查询出需要显示的记录
		rs = sm.executeQuery("select username,ruzhi,jingyan,iskaohe,isallow from zhuanzheng where  dept = '"+dept+"' order by username "+" limit "
				+ (pageNow - 1) * pageSize + "," + pageSize);
	%>

	<table width="100%" border="0" cellpadding="0" cellspacing="1"
		bgcolor="#BBD3EB">
		<tr>
			<td height="27" align="center"
				background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">员工</td>
			<td height="27" align="center"
				background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">入职时间</td>
			<td height="27" align="center"
				background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">掌握技能和工作</td>
			<td height="27" align="center"
				background="/OA/admin/images/index1_72.gif" bgcolor="#FFFFFF">通过的考核</td>
			<td align="center" background="/OA/admin/images/index1_72.gif"
				bgcolor="#FFFFFF">审批状态</td>
			<td align="center" background="/OA/admin/images/index1_72.gif"
				bgcolor="#FFFFFF">操作</td>
		</tr>
		<%
			while (rs.next()) {
		%>
		<tr>
			<td height="26" align="center" bgcolor="#FFFFFF"><%=rs.getString(1)%></td>
			<td height="26" align="center" bgcolor="#FFFFFF"><%=rs.getString(2)%></td>
			<td height="26" align="center" bgcolor="#FFFFFF"><%=rs.getString(3)%></td>
			<td height="26" align="center" bgcolor="#FFFFFF"><%=rs.getString(4)%></td>
			<td height="26" align="center" bgcolor="#FFFFFF"><%=rs.getString(5)%></td>
			<td height="26" align="center" bgcolor="#FFFFFF">
                            <%if(rs.getString(5).equals("待审批")){ %>
                            <a href="zzspty?username=<%=rs.getString(1) %>">同意</a>
                            |
                            <a href="zzspjj?username=<%=rs.getString(1) %>">拒绝</a>
                            <%} %>
                            </td>
		</tr>
		<%
			}
		%>

	</table>
	<table width="100%" border="0" cellpadding="0" cellspacing="1"
		bgcolor="#BBD3EB">

		<%
			//上一页
			if (pageNow != 1) {
				out.println("<a href=admin/zzsp.jsp?pageNow=" + (pageNow - 1)
						+ ">上一页</a>");
			}
			//显示超链接
			for (int i = 1; i <= pageCount; i++) {
				out.println("<a href=admin/zzsp.jsp?pageNow=" + i + ">[" + i
						+ "]</a>");
			}
			//下一页
			if (pageNow != pageCount) {
				out.println("<a href=admin/zzsp.jsp?pageNow=" + (pageNow + 1)
						+ ">下一页</a>");
			}
		%>
	</table>
</body>
</html>